package com.sunop.pantiproblem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.sunop.pantiproblem.model.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

/**
 * @author hutao666123
 * @since 2025-03-18
 */
@Mapper
public interface ProblemMapper extends BaseMapper<Problem> {

    List<ProblemVO> pageQueryByTitle(List<Integer> pidList, int pageNum, int pageSize) ;

    @Insert("insert into problem_in_out (pid, input, output) values (#{pid}, #{input}, #{output})")
    void saveInOut(ProblemInOutputData problemInOutputData);

    Page<ProblemVO> pageQuery(ProblemPageQueryDTO problemPageQuery);


    @Select("select input from problem_in_out where pid = #{pid}")
    String findInById(int pid);

    @Select("select output from problem_in_out where pid = #{pid}")
    String getOutput(int pid);

    @Select("select time_limit,memory_limit from problem where id = #{pid}")
    Map<String, BigInteger> selectTimeById(int pid);

    @Insert("insert into user_record (uid, pid, massage, runtime, memory, code, language, score_average, create_time, problem_title) values (#{uid}, #{pid}, #{massage}, #{runtime}, #{memory}, #{code}, #{language}, #{scoreAverage}, #{createTime}, #{problemTitle})")
    void saveRecode(UserRecodeVO userRecodeVO);

    @Select("select title, difficulty from problem where id = #{pid}")
    Map<String, String> getTitleAndDifficulty(int pid);

    @Select("select id ,title, difficulty,tag,submit_num,pass_num from problem where difficulty = #{difficulty} and tag = #{tag}")
    Problem getProblemsByAI(Integer difficulty, String tag);
}
